import request from '@/utils/request'

const api_name = '/admin/product'

export default {
  getSaleAttrList() {
    return request.get(`${api_name}/baseSaleAttrList`)
  },
  remove(spuId) {
    return request.delete(`${api_name}/deleteSpu/${spuId}`)
  },

  get(spuId) {
    return request.get(`${api_name}/getSpuById/${spuId}`)
  },

  addUpdate(spuInfo) {
    return request({
      url: `${api_name}/${spuInfo.id ? 'update' : 'save'}SpuInfo`,
      method: 'POST',
      data: spuInfo
    })
  },

  getList(page, limit, category3Id) {
    return request({
      url: `${api_name}/${page}/${limit}`,
      method: 'GET',
      params: { category3Id }
    })
  },

  findSpuInfoByKeyword(keyword) {
    return request({
      url: `${api_name}/findSpuInfoByKeyword/${keyword}`,
      method: 'get'
    })
  }
}
